package Selenium.MyAccount;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.ie.InternetExplorerDriver;
import Selenium.CommonFunctions.AdvanceFindElementFunctions;
import Selenium.XMLReaders.XMLClass;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;;


@SuppressWarnings("unused")
public class MyAccountMainCode {

	/**
	 * @param args
	 */
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub		
		//This file is the main code to run MyAccount related tests		
		
		XMLClass XMLObj;		
		XMLObj = new XMLClass("D:/SeleniumJavaCode/SeleniumSniffSuite/src/TestData/GlobalNavTestData.xml");
		org.w3c.dom.NodeList Node1;
		Node n;
		n = XMLObj.GetChildfromParent("TestData", "TestName", "GlobalNavExistenceCheck");	
		Element x = (Element)n;
		Node1 = x.getElementsByTagName("TestRelativeUrl");
		
		//XMLObj.GetChildNodes(n, "TestData");
		System.out.println("The count of nodes is: " + Node1.getLength());
		
		for (int i = 0; i <= Node1.getLength() - 1; i ++)
		{			
			System.out.println(Node1.item(i).getNodeName());
			System.out.println("Node number: " + i + "Node Value: " + Node1.item(i).getTextContent());		
		}

		System.out.println("This is where the selenium starts");
		//////
		FirefoxProfile FFProfile = new FirefoxProfile();
		FFProfile.setAcceptUntrustedCertificates(true);
		WebDriver MozillaWebDriver = new FirefoxDriver(FFProfile);	
		System.out.println("Successfully created a mozilla browser");
		MozillaWebDriver.get("http://delvmplmmcfp05.sapient.com/webapp/wcs/stores/servlet/en/marksandspencer/women/dresses");
		System.out.println("Successfully navigate to the desired page browser");
		System.out.println("Trying to create a global header object");
		GlobalHeaderClass GlobalHeader = new GlobalHeaderClass(MozillaWebDriver);
		System.out.println("Created a global header object");
		System.out.println("Global navigation exists: " + GlobalHeader.GlobalNavObjectExists);
		System.out.println("We are done till now");
		
		//script to Global headers
		VerifyLinkGlobalHeader.main(GlobalHeader);		
		GlobalHeader.GlobalNavClickableObjects.Register.click();
		System.out.println("Creating a Registration form object");
		MozillaWebDriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);		
		RegistrationModuleClass RegistrationForm = new RegistrationModuleClass(MozillaWebDriver);
		System.out.println("Created a Registration form object");
		System.out.println("Registration form  exists: " + RegistrationForm.RegisterFrameExists);
		System.out.println("We are done till now");
		//VerifyObjectsRegistrationForm();
		//Create a user test VerifyRegistrationProcess test
		VerifyRegistrationProcess.main(RegistrationForm, "testuser", "test3233", "gmail1@yuuu.com");
		
		

	}

}
